package com.ldzy.webase.dao;

import com.ldzy.webase.entity.PaoOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author ：Lq
 * @version ：1.0
 * @date ：2022/12/2 11:04
 * @description ：t_pao_order-跑腿任务单表-数据层
 */
public interface PaoOrderMapper {
    // 查询所有还未接单的跑腿任务单并排序
    // 可分页查询
    @Select("<script>" +
            "select pao.*,u.username,u.avatar " +
            "from t_pao_order as pao " +
            "left join t_user u on u.uid = pao.publishUid " +
            "<where> " +
            "(pao.receiverUid is null or pao.receiverUid='') and " +
            "pao.orderStatus=0 " +
            "</where>" +
            "order by " + // 排序，当数值相同时会进行下一个排序的序号，顺序为：1.根据悬赏金排序 2.根据发布时间排序
            "pao.orderMoney desc," +
            "pao.publishDate desc " +
            "<if test=\"curPage != null and pageSize != null\"> " +
            "LIMIT #{pageSize} OFFSET #{curPage} " +
            "</if>" +
            "</script>")
    List<PaoOrder> getAllPaoOrder(@Param("curPage") Integer curPage, @Param("pageSize") Integer pageSize);
}
